﻿using CoachingOrganizer.Toolkit.Events;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CoachingOrganizer.Logic.Models.Tools.MoodLevel
{
    public class MoodDayCacheModel
    {
        private readonly DateTime _date;
        private MoodValueCacheModel[] _values;

        public DateTime Date
        {
            get { return _date; }
        }

        public MoodValueCacheModel[] Values
        {
            get { return _values; }
            internal set { _values = value; }
        }

        internal Func<Task<ActionResult>> SaveDelegate;

        public MoodDayCacheModel(DateTime date)
        {
            _date = date;
        }

        public async Task<ActionResult> Save()
        {
            Func<Task<ActionResult>> saveDelegate = SaveDelegate;
            return saveDelegate == null ? ActionResult.GetErrorResult(new NotSupportedException()) : await saveDelegate();
        }
    }
}
